package com.ljkj.blockpay.presenter;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import com.kongzue.baseokhttp.HttpRequest;
import com.kongzue.baseokhttp.listener.JsonResponseListener;
import com.kongzue.baseokhttp.util.JsonList;
import com.kongzue.baseokhttp.util.JsonMap;
import com.kongzue.baseokhttp.util.Parameter;
import com.ljkj.blockpay.basedata.BasePresenterImpl;
import com.ljkj.blockpay.model.CommonModel;
import com.ljkj.blockpay.network.ApiToCConfig;
import com.ljkj.blockpay.network.MainRepository;
import com.ljkj.blockpay.network.response.BaseResponse;
import com.ljkj.blockpay.network.response.DisposableCallBack;
import com.ljkj.blockpay.presenter.inter.SelectInter;
import com.luck.picture.lib.tools.ToastUtils;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;


/**
 * Created by yp on 2022/3/9
 */
public class SelectPresenter extends BasePresenterImpl<SelectInter.SelectInterView> implements SelectInter.SelectInterPresenter {


    public SelectPresenter(@NonNull Context context, @NonNull SelectInter.SelectInterView view) {
        super(context, view);
    }


    @Override
    public void CountryCode() {
        HttpRequest.GET(getContext(), ApiToCConfig.URL_COUNTRY_CODE, new Parameter(), new JsonResponseListener() {
            @Override
            public void onResponse(JsonMap main, Exception error) {
                if (main.getInt("code") == 0){
                    JsonList data = main.getList("data");
                    getView().countryListSuccess(data);
                }
            }
        });
//        addDisposable(MainRepository.getInstance().getValidateCode()
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribeWith(new DisposableCallBack<List<CommonModel>>() {
//                    @Override
//                    public void onSuccess(BaseResponse<List<CommonModel>> baseResponse) {
//                        super.onSuccess(baseResponse);
//                        getView().getCountryCode(baseResponse.data);
//                    }
//
//                    @Override
//                    protected void onSafeFailed(String code, String message) {
//                        super.onSafeFailed(code, message);
//                    }
//                }));
    }
}
